
package nav;

import java.util.Collection;
import java.util.HashMap;

public class CrossingCollectionImpl implements CrossingCollection{

	private HashMap<Integer, Crossing> crossings = new HashMap<Integer, Crossing>();
	
    public CrossingCollectionImpl(){

    }

	@Override
	public boolean exists(int id) {
		if(crossings.containsKey(id)){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public void addCrossing(Crossing crossing) {
		crossings.put(crossing.getID(), crossing);
	}

	@Override
	public Crossing getCrossing(int id) {
		return crossings.get(id);
	}

	@Override
	public Collection<Crossing> getAllCrossings(){
		return crossings.values();
	}

	@Override
	public void clear() {
		crossings.clear();
	}
}
